﻿
using Xacml.Core;
using System;
using System.Xml;

namespace Xacml.Core.Context
{
  public class ContextDocument : ContextDocumentReadWrite
  {
    public override RequestElementReadWrite Request
    {
      get
      {
        SubjectCollection subjects = (SubjectCollection) null;
        ActionElement action = (ActionElement) null;
        EnvironmentElement environment = (EnvironmentElement) null;
        ResourceCollection resources = (ResourceCollection) null;
        if (base.Request.Subjects != null)
          subjects = new SubjectCollection(base.Request.Subjects);
        if (base.Request.Action != null)
          action = new ActionElement(new AttributeCollection(base.Request.Action.Attributes), base.Request.Action.SchemaVersion);
        if (base.Request.Environment != null)
          environment = new EnvironmentElement(new AttributeCollection(base.Request.Environment.Attributes), base.Request.Environment.SchemaVersion);
        if (base.Request.Resources != null)
          resources = new ResourceCollection(base.Request.Resources);
        return (RequestElementReadWrite) new RequestElement(subjects, resources, action, environment, base.Request.SchemaVersion);
      }
      set
      {
        throw new NotSupportedException();
      }
    }

    public ContextDocument()
    {
    }

    public ContextDocument(XmlReader reader, XacmlVersion schemaVersion)
      : base(reader, schemaVersion)
    {
    }
  }
}
